# -*- coding: utf-8 -*-
import maya.cmds as cmds
print("========================================================")
class Check_CamName():
	def Check_CamName(self):
		file_path = cmds.file(q=True, sceneName=True)
		file_name = file_path.split("/")[-1]
		file_name = file_name.split("_")
		#cameras = cmds.ls(type="camera")
		ListCam_list = [i for i in cmds.listCameras (p = 1) if i != "persp"]
		Old_Cam= ''

		ListCam =ListCam_list[0]
		if cmds.nodeType (ListCam) == "camera" :
			Old_Cam = cmds.listRelatives (ListCam , p = True)[0]
		else :
			Old_Cam = ListCam
		if len (ListCam_list) == 1 :
			try :
				if not cmds.camera (Old_Cam , query = True , startupCamera = True) :
					cmds.rename (Old_Cam , file_name[0] + "_" + file_name[1] + "_cam")
					print(file_name[0] + "_" + file_name[1] + "_cam")
					return ("YES")
			except :
				return ("NO-未知错误-手动检查文件")
		else :
			return ("NO-存在多余相机"+str(ListCam_list))
